package com.xiyou.io.week05.service.impl;

import com.xiyou.io.week05.dao.mapper.UserMapper;
import com.xiyou.io.week05.dao.model.User;
import com.xiyou.io.week05.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 新增
     *
     * @param user
     */
    @Override
    public void add(User user) {
        userMapper.insert(user);
    }

    /**
     * 编辑
     *
     * @param user
     */
    @Override
    public void edit(User user) {
        userMapper.updateById(user);
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public void delete(Integer id) {
        userMapper.deleteById(id);
    }

    /**
     * 根据ID查询
     *
     * @param id
     */
    @Override
    public User getById(Integer id) {
        return userMapper.selectById(id);
    }

}
